#include "CircleCreateAction.h"

using namespace cmn;
using namespace editor_core;

CircleCreateAction::CircleCreateAction( const Circle& circle, IProvider<BodyEntity*>* parentBodyProvider ) :
	m_circle( circle ),
	m_parentBodyProvider( parentBodyProvider ),
	m_circleEntity( 0 )
{}

CircleCreateAction::~CircleCreateAction() {}

bool CircleCreateAction::Commit() {
	BodyEntity* parentBody = m_parentBodyProvider->GetEntity();

	m_circleEntity = new CircleEntity( parentBody, m_circle );
	parentBody->AddCircle( m_circleEntity );
	return true;
}

void CircleCreateAction::Rollback() {
	BodyEntity* parentBody = m_parentBodyProvider->GetEntity();

	parentBody->RemoveCircle( m_circleEntity );
	delete m_circleEntity;
	m_circleEntity = 0;
}

void CircleCreateAction::Recommit() {
	Commit();
}

